package app.netant.book.feisuxs;

import org.jsoup.select.Elements;

import app.netant.book.base.BaseDetail;

public class FeisuxsDetail extends BaseDetail {

	public FeisuxsDetail(String netSite) {
		super(netSite);
		this.preHref = "http://www.feisuxs.net";
	}

	@Override
	public void analyseTitle() {
		Elements parts = this.select("#wrapper .box_con #maininfo #info h1");
		if(parts.size()>0){
			
			String title = parts.get(0).text().trim();
			System.out.println("【Title】:"+title);
			
			this.entity.setNovelName(title);
			this.entity.setNovelFullName(title+".txt");
		}
		
	}

	@Override
	public void analyseTags() {
		
		Elements parts = this.select("#wrapper .box_con #maininfo #info p");
		for(int i=0;i<parts.size();i++){
			String text = this.getString(parts.get(i).text().replaceAll(" ", ""));
			int idx = text.indexOf("：");
			String tagName = text.substring(0,idx).trim();
			String tagValue = text.substring(idx+1).trim();
			System.out.println("【Tag】:"+tagName+"="+tagValue);
			this.entity.setTag(tagName, tagValue);
			
			if("下载".equals(tagName)){
				
				String href = parts.get(i).select("a").get(0).attr("href");
				System.out.println("【Href】:"+href);
				this.entity.setDownPath(href);
			}
			
		}
		
	}

	@Override
	public void analyseMemo() {
		Elements parts = this.select("#wrapper .box_con #maininfo #intro");
		if(parts.size()>0){
			String memo = parts.get(0).text();
			System.out.println("【Memo】:"+memo);
			this.entity.setNovelMemo(memo);
		}	
	}

	@Override
	public void analyseHref() {
		
	}
	
	@Override
	public void analyseType() {
		
	}
	
	public static void main(String[] args) {
		FeisuxsDetail detail = new FeisuxsDetail("http://www.feisuxs.net/book/277/277788/");
		detail.test();
	}



}
